/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "my_contact")
public class MyContact extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "MyContact";
	public static final String ALIAS_MY_CONTACT_ID = "myContactId";
	public static final String ALIAS_MEMBER_ID = "memberId";
	public static final String ALIAS_PUBLISH_INFO_ID = "publishInfoId";
	public static final String ALIAS_TRADE_TIME = "tradeTime";
	
	//date formats
	public static final String FORMAT_TRADE_TIME = DATE_FORMAT;
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * myContactId       db_column: myContactId 
     */ 	
	
	private java.lang.Long myContactId;
    /**
     * memberId       db_column: memberId 
     */ 	
	
	private java.lang.Long memberId;
    /**
     * publishInfoId       db_column: publishInfoId 
     */ 	
	
	private java.lang.Long publishInfoId;
    /**
     * tradeTime       db_column: tradeTime 
     */ 	
	@NotNull 
	private java.util.Date tradeTime;
	
	private java.util.Date endTime;
	
	private Integer status;
	//columns END


	public MyContact(){
	}

	public MyContact(
		java.lang.Long myContactId
	){
		this.myContactId = myContactId;
	}

	

	public void setMyContactId(java.lang.Long value) {
		this.myContactId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "myContactId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMyContactId() {
		return this.myContactId;
	}
	
	@Column(name = "memberId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getMemberId() {
		return this.memberId;
	}
	
	public void setMemberId(java.lang.Long value) {
		this.memberId = value;
	}
	
	@Column(name = "publishInfoId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getPublishInfoId() {
		return this.publishInfoId;
	}
	
	public void setPublishInfoId(java.lang.Long value) {
		this.publishInfoId = value;
	}
	
	@Transient
	public String getTradeTimeString() {
		return DateConvertUtils.format(getTradeTime(), FORMAT_TRADE_TIME);
	}
	public void setTradeTimeString(String value) {
		setTradeTime(DateConvertUtils.parse(value, FORMAT_TRADE_TIME,java.util.Date.class));
	}
	
	@Column(name = "tradeTime", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	public java.util.Date getTradeTime() {
		return this.tradeTime;
	}
	
	public void setTradeTime(java.util.Date value) {
		this.tradeTime = value;
	}
	
	
	private PublishInfo publishInfo;
	public void setPublishInfo(PublishInfo publishInfo){
		this.publishInfo = publishInfo;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "publishInfoId",nullable = false, insertable = false, updatable = false) 
	})
	public PublishInfo getPublishInfo() {
		return publishInfo;
	}
	
	private Members members;
	public void setMembers(Members members){
		this.members = members;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "memberId",nullable = false, insertable = false, updatable = false) 
	})
	public Members getMembers() {
		return members;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("MyContactId",getMyContactId())
			.append("MemberId",getMemberId())
			.append("PublishInfoId",getPublishInfoId())
			.append("TradeTime",getTradeTime())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getMyContactId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof MyContact == false) return false;
		if(this == obj) return true;
		MyContact other = (MyContact)obj;
		return new EqualsBuilder()
			.append(getMyContactId(),other.getMyContactId())
			.isEquals();
	}
	@Transient
	public String getEndTimeString() {
		return DateConvertUtils.format(getEndTime(), FORMAT_TRADE_TIME);
	}
	public void setEndTimeString(String value) {
		setTradeTime(DateConvertUtils.parse(value, FORMAT_TRADE_TIME,java.util.Date.class));
	}
	
	@Column(name = "endTime", unique = false, nullable = false, insertable = true, updatable = true, length = 0)
	public java.util.Date getEndTime() {
		return endTime;
	}

	public void setEndTime(java.util.Date endTime) {
		this.endTime = endTime;
	}

	@Column(name = "status", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}

